﻿using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace LogisticsAdmin
{
    public partial class GameNews : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            BindTeamList();
        }
        private void BindTeamList()
        {
            //1、sql语句
            string sql = "SELECT  * FROM dbo.TruckTeam";
            //2、执行sql获取列表信息---SqlDataReader---   list<TruckTeamModel>
            SqlDataReader sdr = SQLHelper.ExecuteReader(sql);
            List<TruckTeamModel> truckTeams = new List<TruckTeamModel>();
            if (sdr.HasRows)
            {
                while (sdr.Read())
                {
                    TruckTeamModel teamModel = new TruckTeamModel();
                    teamModel.TeamID = Convert.ToInt32(sdr["TeamID"]);
                    teamModel.TeamName = sdr["TeamName"].ToString();
                    teamModel.Remark = sdr["Remark"].ToString();
                    truckTeams.Add(teamModel);
                }
                sdr.Close();
            }
            //3、赋值给数据源控件
            rptGameNewsList.DataSource = truckTeams;
            rptGameNewsList.DataBind();
        }
    }
}